﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HQWeb.SysManage.RoleManage
{
    public partial class RoleTree : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            VerdictIsLogin();
            if (!Page.IsPostBack)
            {
                InitTree();
            }
        }
        #region 绑定角色树型

        private void InitTree()
        {

            TreeNode node = new TreeNode();
            node.Text = "喜来婚庆公司";
            node.Value = "";
            node.NavigateUrl = "RoleList.aspx";
            node.Target = "ShowRoleList";
            node.Expanded = true;
            LeftTree.Nodes.Add(node);
            BLL.SysManage.T_PUB_ROLE roleBll = new BLL.SysManage.T_PUB_ROLE();
            List<Model.SysManage.T_PUB_ROLE> modelList = roleBll.GetModelList("");
            AddReplies(node, modelList);

        }
        private void AddReplies(TreeNode node, List<Model.SysManage.T_PUB_ROLE> modelList)
        {


            foreach (Model.SysManage.T_PUB_ROLE roleListModel in modelList)
            {
                TreeNode replyNode = new TreeNode();
                replyNode.Text = roleListModel.ROLE_NAME;
                replyNode.Value = roleListModel.ROLE_ID.ToString();
                //replyNode.ImageUrl = row["TreeIco"].ToString();
                replyNode.NavigateUrl = "RoleUser.aspx?ID=" + replyNode.Value;
                replyNode.Target = "ShowRoleList";
                replyNode.Expanded = false;
                node.ChildNodes.Add(replyNode);

            }
        }

        #endregion
    }
}